import request from '@/utils/request'

// 登录方法
export function login(username, password, code, uuid) {
  return request({
    url: '/auth/login',
    headers: {
      isToken: false
    },
    method: 'post',
    data: { username, password, code, uuid }
  })
}

//新写的登录接口
export function loginNew(username, password, code ) {
  return request({
    url: `/api/login/login`,
    headers: {
      isToken: false
    },
    method: 'post',
    data: { mobile: username, pwd: password, code }
  })
}

// 注册方法
export function register(data) {
  return request({
    url: '/api/Login/register',
    headers: {
      isToken: false
    },
    method: 'post',
    data: data
  })
}

// 忘记密码
export function forgetPassword(data) {
  return request({
    url: '/api/Login/forget',
    headers: {
      isToken: false
    },
    method: 'post',
    data: data
  })
}

// 刷新方法
export function refreshToken() {
  return request({
    url: '/auth/refresh',
    method: 'post'
  })
}

// 获取用户详细信息
export function getInfo() {
  return request({
    url: '/api/user/getUserInfo',
    method: 'get'
  })
}

// 退出方法
export function logout() {
  return request({
    url: '/api/login/logout',
    method: 'post'
  })
}

// 获取验证码
export function getCodeImg() {
  return request({
    url: '/api/tool/getCaptcha',
    headers: {
      isToken: false
    },
    method: 'get',
    timeout: 20000
  })
}

// 获取手机号验证码
export function getPhoneCode(data) {
  return request({
    url: '/api/Tool/sendCode',
    headers: {
      isToken: false
    },
    method: 'post',
    data: data
  })
}

// 统一认证鉴权接口
export function ssoLogin(ssoToken) {
  return request({
    url: '/auth/ssoLogin?ssoToken='+ssoToken,
    headers: {
      isToken: false
    },
    method: 'get',
  })
}
